#include "StdAfx.h"
#include "Util.h"

Util::Util(void)
{
}

Util::~Util(void)
{
}

DWORD Util::swap_uint32( DWORD val )
{
    val = ((val << 8) & 0xFF00FF00 ) | ((val >> 8) & 0xFF00FF ); 
    return (val << 16) | (val >> 16);
}

void Util::arraycopy(char* dest, int despos, const char* src, int srcpos, int length)
{
	arrayjoin(dest + despos, src + srcpos, length);
}

void Util::arrayjoin(char* to, const char* from, int count)
{
	if (from > to)
	{
		char *end = (char*)(from + count);
		while (from < end)
			*(to++) = *(from++);
	}
	else if (from < to)
	{
		char *end = (char*)(from);
		from += count - 1;
		to   += count - 1;
		while (from >= end)
			*(to--) = *(from--);
	}
}
